package buddha.domain;
// default package

import buddha.domain.User;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;


/**
 * Authority entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name="t_authority")
public class Authority  implements java.io.Serializable {


    // Fields    

     private Integer id;
     private String name;
     private String path;
     private Authority parent;
     private Set<User> users = new HashSet<User>(0);
     private Set<Authority> children = new HashSet<Authority>();


    // Constructors

    /** default constructor */
    public Authority() {
    }

    
    /** full constructor */
    public Authority(String name, String path, Authority parent, Set<User> users, Set<Authority> children) {
        this.name = name;
        this.path = path;
        this.parent = parent;
        this.users = users;
        this.children = children;
    }

   
    // Property accessors
    @GenericGenerator(name="generator", strategy="increment")@Id @GeneratedValue(generator="generator")
    
    @Column(name="id", unique=true, nullable=false)

    public Integer getId() {
        return this.id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
    
    @Column(name="name", length=50)

    public String getName() {
        return this.name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    @Column(name="path", length=200)

    public String getPath() {
        return this.path;
    }
    
    public void setPath(String path) {
        this.path = path;
    }
    
    
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="parent")
    public Authority getParent() {
		return parent;
	}


	public void setParent(Authority parent) {
		this.parent = parent;
	}


	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="authorities")
    public Set<User> getUsers() {
        return this.users;
    }
    
    public void setUsers(Set<User> TUsers) {
        this.users = users;
    }

    @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="parent")
	public Set<Authority> getChildren() {
		return children;
	}


	public void setChildren(Set<Authority> children) {
		this.children = children;
	}
	
	
   
}